#define  _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

typedef struct ListNode ListNode;
struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2) {
    if (list1 == NULL)
    {
        return list2;
    }
    if (list2 == NULL)
    {
        return list1;
    }

    ListNode* phead = (ListNode*)malloc(sizeof(ListNode));
    phead->val = 0;
    phead->next = NULL;

    ListNode* cur1 = list1;
    ListNode* cur2 = list2;
    ListNode* cur = phead;

    while (cur1 != NULL && cur2 != NULL)
    {
        if (cur1->val <= cur2->val)
        {
            cur->next = cur1;
            cur = cur->next;
            cur1 = cur1->next;

            if (cur1 == NULL)
            {
                cur->next = cur2;
                return phead->next;
            }
        }
        if (cur1->val > cur2->val)
        {
            cur->next = cur2;
            cur = cur->next;
            cur2 = cur2->next;

            if (cur2 == NULL)
            {
                cur->next = cur1;
                return phead->next;
            }
        }
    }


    return phead->next;
}
int main()
{


	return 0;
}